home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group00b.txt
/
000107_icon-group-sender_Wed Oct 25 08:08:53 2000.msg
< prev
next >
Wrap
Internet Message Format
|
2001-01-03
|
2KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id e9PF8eP09361
for icon-group-addresses; Wed, 25 Oct 2000 08:08:40 -0700 (MST)
Message-Id: <200010251508.e9PF8eP09361@baskerville.CS.Arizona.EDU>
Date: Tue, 24 Oct 2000 17:30:29 -0700 (PDT)
From: Shamim Mohamed <shamim@drones.com>
To: "Charles Hethcoat" <CHETHCOA@oss.oceaneering.com>
Cc: <icon-group@cs.arizona.edu>
Subject: Re: How to "declare" a string?
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 1427
Charles Hethcoat replies to someone's question:
>
> > So again I'm back to the quesiton, "How to 'declare' a string variable?"
>
> I don't know if this will help answer the question, which I am
> admittedly quite confused about. However, a few smart tests can take
> you far.
Actually, an attentive reading of Griswold and Griswold will help more
than running tests; that way you don't have to try to figure out what
the language is doing, the book tells you exactly what's happening.
> ... my guess is that the line
>
> s2[2] := s1
>
> is ambiguous. s2 could be a string OR a table. Either one would be
> syntactically correct.
I fear you are getting too hung up on syntax. When icont sees s2[2], it
generates instructions for the interpreter iconx: "apply the subscript
operator to the value stored in the variable s2 with the index 2". And
what value is stored in s2 when execution reaches that line? The null
value &null, which cannot accept a subscript operation. Ergo runtime
error. Remember, icont does not do the type-checking, iconx does.
(Values that the subscript operator [] can be applied to are: strings,
csets, lists, tables, ...)
To the original writer: don't think too much about types of variables.
That is an artifact of languages like C or Pascal. Think about values
having types, variables are just pigeonholes for these typed values. A
variable can hold a value of any type.
-s